Jump to content

Ο Χάρος

Members
  • Posts

    46
  • Credits

  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Ο Χάρος

  1. 23 minutes ago, Solomun said:

    [GR] Δεν το ειπα ηρωνικα ουτε μαγκας προσπαθω να το παιξω...λολ

     

    Τι σε εμποδιζει απο το να κανεις αυτο που σου ειπα?

    [GR] Πολλες ωρες για να κανεις το project convert σε java 8 [/GR]

  2. 28 minutes ago, .Elfocrash said:

    What i would do is this:

    Creatin a new method called addSkills which allows an array of skills to be handled. You will need old and new skill separation for update and add

    So process so far. I did what i wrote. Created new Map, stored each new skill on it. Changed the addSkill from true to false so it wont store individualy

    at the end of the class i added the storeSkills. The method simply store all L2Skills at once without open 1000 DB con. Still in game 1.5 sec delay like i never changed anything.

    The method turns out to Finalize after 77 milliseconds. I refer to this method 

    public int giveAvailableSkills(final boolean includedByFs, final boolean includeAutoGet)
    	{
    		long ms = System.currentTimeMillis();
    		
    		int unLearnable = 0;
    		int skillCounter = 0;
    
    		List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableSkills(this, getClassId(), includedByFs, includeAutoGet);
    		List<L2Skill> skillsForStore = new ArrayList<>();
    		
    		while (skills.size() > unLearnable)
    		{
    			for (final L2SkillLearn s : skills)
    			{
    				final L2Skill sk = SkillTable.getInstance().getInfo(s.getSkillId(), s.getSkillLevel());
    				if (sk == null || sk.getId() == L2Skill.SKILL_DIVINE_INSPIRATION && !Config.AUTO_LEARN_DIVINE_INSPIRATION && !isGM())
    				{
    					unLearnable++;
    					continue;
    				}
    				if (getSkillLevel(sk.getId()) == -1)
    				{
    					skillCounter++;
    				}
    				// fix when learning toggle skills
    				if (sk.isToggle())
    				{
    					final L2Effect toggleEffect = getFirstEffect(sk.getId());
    					if (toggleEffect != null)
    					{
    						// stop old toggle skill effect, and give new toggle
    						// skill effect back
    						toggleEffect.exit();
    						sk.getEffects(this, this);
    					}
    				}
    				addSkill(sk, false); //addSkill(sk, true);
    				skillsForStore.add(sk);
    			}
    			skills = SkillTreesData.getInstance().getAvailableSkills(this, getClassId(), includedByFs, includeAutoGet);
    		}
    		
    		storeSkills(skillsForStore, -1);
    		
    		if (Config.AUTO_LEARN_SKILLS && (skillCounter > 0))
    		{
    			sendMessage("You have learned " + skillCounter + " new skills.");
    		}
    		
    		System.out.println(System.currentTimeMillis() - ms);
    		return skillCounter;
    	}

     

    So either the SQL data in Freya is shit as u said or client relative... idk any suggestion or could we implement HikariCP ?B

    But again if it was SQL slow, it would be captured on the system.out..  it would say 3500 millisecond or something no 35... cause in this berchmark the sql con is included.

    So it might be client lag? But i tried rotate immidiately after i get the skill list and the L2 respond fine, it rotate perfectly just the char doesnt move and suddedly he move x10 fast to the spot 

    i clicked.

  3. Just now, .Elfocrash said:

    What i would do is this:

    Creatin a new method called addSkills which allows an array of skills to be handled. You will need old and new skill separation for update and add

    Ok i did. Ill go check in game to see the thread how much time it get sleep until db stuff finish. Thanks for ur help i wouldnt search further if u didn't say the word "DB" .

    I kinda liked procedures in SQL but the overal structure and coding i dont like it. 

  4. Just now, .Elfocrash said:

    Well realistically what you can do now is to batch the datain the prepared statement and execute the batch. This should use one connection.

    Here is an example in case you don't know what im talking about: https://www.mkyong.com/jdbc/jdbc-preparedstatement-example-batch-update/

    However all this should be asynchronous but no one bothers to optimize performance in sql because they dont know how.

    I set the addSkill(skill, false); so it won't store each skill individual using DB

    and bellow i add the skill onto a List  and at the end of the code i call this method that i added

    private void storeSkills(List<L2Skill> newSkills, int newClassIndex)
    	{
    		if (newSkills.isEmpty())
    		{
    			return;
    		}
    		
    		final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
    		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
    			PreparedStatement ps = con.prepareStatement(ADD_NEW_SKILLS))
    		{
    			con.setAutoCommit(false);
    			for (final L2Skill addSkill : newSkills)
    			{
    				
    				ps.setInt(1, getObjectId());
    				ps.setInt(2, addSkill.getId());
    				ps.setInt(3, addSkill.getLevel());
    				ps.setInt(4, classIndex);
    				ps.addBatch();
    			}
    			ps.executeBatch();
    			con.commit();
    		}
    		catch (SQLException e)
    		{
    			
    		}
    	}

    Which simply open 1 DB c and store all together. But how faster the HikariCP is? Can i upgrade to it? im not sql fan.

  5. Just now, .Elfocrash said:

    Ofc there would be sql related stuff. There is no way simple datastructures would lock things like this.

    This look is draining the shit out of the db pool. H5 is only faster because it is using HikariCP (and potentially better code) which allows a bigger amound of connections in the pool to be used.

    I'm not the best in SQL, what u suggest?  Maybe instead of open 1 connection for each skill to add all in 1 map and open 1 con and do a for e.t.c ? wouldnt this be faster?

    Else what ? 

  6. Damn it, the     addSkill(sk, true); 

    at the code i showed you have  SQL relative code pff

    public L2Skill addSkill(final L2Skill newSkill, final boolean store)
    	{
    		// Add a skill to the L2PcInstance _skills and its Func objects to the
    		// calculator set of the L2PcInstance
    		final L2Skill oldSkill = super.addSkill(newSkill);
    		// Add or update a L2PcInstance skill in the character_skills table of
    		// the database
    		if (store)
    		{
    			storeSkill(newSkill, oldSkill, -1);
    		}
    		return oldSkill;
    	}

    You were right... damn this fucking SQL. 

    private void storeSkill(final L2Skill newSkill, final L2Skill oldSkill, final int newClassIndex)
    	{
    		int classIndex = _classIndex;
    		if (newClassIndex > -1)
    		{
    			classIndex = newClassIndex;
    		}
    		Connection con = null;
    		try
    		{
    			con = L2DatabaseFactory.getInstance().getConnection();
    			PreparedStatement statement;
    			if (oldSkill != null && newSkill != null)
    			{
    				statement = con.prepareStatement(UPDATE_CHARACTER_SKILL_LEVEL);
    				statement.setInt(1, newSkill.getLevel());
    				statement.setInt(2, oldSkill.getId());
    				statement.setInt(3, getObjectId());
    				statement.setInt(4, classIndex);
    				statement.execute();
    				statement.close();
    			}
    			else if (newSkill != null)
    			{
    				statement = con.prepareStatement(ADD_NEW_SKILL);
    				statement.setInt(1, getObjectId());
    				statement.setInt(2, newSkill.getId());
    				statement.setInt(3, newSkill.getLevel());
    				statement.setInt(4, classIndex);
    				statement.execute();
    				statement.close();
    			}
    			else
    			{
    				_log.warning("could not store new skill. its NULL");
    			}
    		}
    		catch (final Exception e)
    		{
    			_log.log(Level.WARNING, "Error could not store char skills: " + e.getMessage(), e);
    		}
    		finally
    		{
    			L2DatabaseFactory.close(con);
    		}
    	}

     

  7. This also have a method i didnt see: 

    activeChar.sendMessage("You gave " + player.giveAvailableSkills(includedByFs, true) + " skills to " + player.getName());

    But the giveAvailableSkills is just this:

    public int giveAvailableSkills(final boolean includedByFs, final boolean includeAutoGet)
    	{
    		int unLearnable = 0;
    		int skillCounter = 0;
    
    		List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableSkills(this, getClassId(), includedByFs, includeAutoGet);
    		while (skills.size() > unLearnable)
    		{
    			for (final L2SkillLearn s : skills)
    			{
    				final L2Skill sk = SkillTable.getInstance().getInfo(s.getSkillId(), s.getSkillLevel());
    				if (sk == null || sk.getId() == L2Skill.SKILL_DIVINE_INSPIRATION && !Config.AUTO_LEARN_DIVINE_INSPIRATION && !isGM())
    				{
    					unLearnable++;
    					continue;
    				}
    				if (getSkillLevel(sk.getId()) == -1)
    				{
    					skillCounter++;
    				}
    				// fix when learning toggle skills
    				if (sk.isToggle())
    				{
    					final L2Effect toggleEffect = getFirstEffect(sk.getId());
    					if (toggleEffect != null)
    					{
    						// stop old toggle skill effect, and give new toggle
    						// skill effect back
    						toggleEffect.exit();
    						sk.getEffects(this, this);
    					}
    				}
    				addSkill(sk, true);
    			}
    			// Get new available skills, some skills depend of previous skills to be available.
    			skills = SkillTreesData.getInstance().getAvailableSkills(this, getClassId(), includedByFs, includeAutoGet);
    		}
    		sendMessage("You have learned " + skillCounter + " new skills.");
    		return skillCounter;
    	}

     

    No db relative or flooding with sendMessage or packet flood. 

  8. Just now, .Elfocrash said:

    Whats in 

    
    player.getAllSkills()

    public final L2Skill[] getAllSkills()
        {
            if (_skills == null)
            {
                return new L2Skill[0];
            }
            return _skills.values().toArray(new L2Skill[_skills.values().size()]);
        }

    Map to array 

  9. Just now, .Elfocrash said:

    There is no way that this is the problem.

    Another obvious pointer would be that H5 is using HikariCP as the default db connection pool while Freya is still c3p0 which is like a million times slower (if somehow db is getting involved).

    Now im thinking it's stupid cause the method was including in berchmark so any sub-calculations wouldnt again be recorded on system out at sendSkillList.. again i tested it nothing changed.. 

    You're right..  No there is no DB connection involved.. I double check the code.

     

    It goes from this: 

    /**
    	 * This function will give all the skills that the target can learn at his/her level
    	 * @param activeChar: the gm char
    	 */
    	private void adminGiveAllSkills(final L2PcInstance activeChar, final boolean includedByFs)
    	{
    		final L2Object target = activeChar.getTarget();
    		L2PcInstance player = null;
    		if (target instanceof L2PcInstance)
    		{
    			player = (L2PcInstance) target;
    		}
    		else
    		{
    			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
    			return;
    		}
    		//Notify player and admin
    		activeChar.sendMessage("You gave " + player.giveAvailableSkills(includedByFs, true) + " skills to " + player.getName());
    		player.sendSkillList();
    	}

    To this 

     

    public void sendSkillList()
    	{
    		sendSkillList(this);
    	}

     

    To this 

     

    public void sendSkillList(final L2PcInstance player)
    	{
    		boolean isDisabled = false;
    		final SkillList sl = new SkillList();
    		
    		if (player != null)
    		{
    			for (final L2Skill s : player.getAllSkills())
    			{
    				if (s == null)
    				{
    					continue;
    				}
    				if (s.getId() > 9000 && s.getId() < 9007)
    				{
    					continue;
    				}
    				if (_transformation != null && !containsAllowedTransformSkill(s.getId()) && !s.allowOnTransform())
    				{
    					continue;
    				}
    				if (player.getClan() != null)
    				{
    					isDisabled = s.isClanSkill() && player.getClan().getReputationScore() < 0;
    				}
    				boolean isEnchantable = SkillTable.getInstance().isEnchantable(s.getId());
    				if (isEnchantable)
    				{
    					final L2EnchantSkillLearn esl = EnchantGroupsTable.getInstance().getSkillEnchantmentBySkillId(s.getId());
    					if (esl != null)
    					{
    						if (s.getLevel() < esl.getBaseLevel())
    						{
    							isEnchantable = false;
    						}
    					}
    					else
    					{
    						isEnchantable = false;
    					}
    				}
    				if (getAioEndTime() > System.currentTimeMillis() && !isGM() && !isInsideZone(ZONE_TOWN))
    				{
    					isDisabled = true;
    				}
    				sl.addSkill(s.getId(), s.getLevel(), s.isPassive(), isDisabled, isEnchantable);
    			}
    		}
    		
    		sendPacket(sl);
    	}

     

    And stops. I use the admin command admin_give_all_skills  So is not SQL relative. Even if it was i have fast disk it wouldnt downgrade so much.

     

  10. Just now, .Elfocrash said:

    Nah the size should be roughly the same. It is the client code that might process it differently in H5

    So basically you say that the size wouldnt change maybe the method that handle the packet is wrong. i check the H5 method SKilLIst and is this https://pastebin.com/AXws0Pgb

    while on freya ishttps://pastebin.com/3HzmwR49

    So basically on Freya the constructor create a new FastList which is slow as fuck compare to arrayList so ill go ahead and change this cause javolution is slower by 30% as i saw

    I'll try my lack with this and report back. 

  11. 6 minutes ago, .Elfocrash said:

    He said the code returns the skills in milliseconds but the client lags. If the method returns data instantly then it is clearly the client.

    If it wasn't then every player would lag not just the one.

     

    I did compare to H5 branch (cause i use freya) and the code is the same (just in H5 they added 1 more check for add the skill on holders) nothing to do with retreive or store. 

    But in H5 it really takes 0.2 sec delay to give 45 skills while in freya it take 1.5 sec delay. I can imagine with extra skills it could take 3 sec delay.

  12. Let me get the things straight:

    This is the admin method that give ALl skills to players.  and the method that does that is the sendSkillList ( same called in sub-class)

    
    	private void adminGiveAllSkills(final L2PcInstance activeChar, final boolean includedByFs)
    	{
    		final L2Object target = activeChar.getTarget();
    		L2PcInstance player = null;
    		if (target instanceof L2PcInstance)
    		{
    			player = (L2PcInstance) target;
    		}
    		else
    		{
    			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
    			return;
    		}
    		player.sendSkillList();
    	}

     

    Now in this method as u can see: 

    public void sendSkillList(final L2PcInstance player)
    	{
    		boolean isDisabled = false;
    		final SkillList sl = new SkillList();
    		
    		if (player != null)
    		{
    			for (final L2Skill s : player.getAllSkills())
    			{
    				if (s == null)
    				{
    					continue;
    				}
    				if (s.getId() > 9000 && s.getId() < 9007)
    				{
    					continue;
    				}
    				if (_transformation != null && !containsAllowedTransformSkill(s.getId()) && !s.allowOnTransform())
    				{
    					continue;
    				}
    				if (player.getClan() != null)
    				{
    					isDisabled = s.isClanSkill() && player.getClan().getReputationScore() < 0;
    				}
    				boolean isEnchantable = SkillTable.getInstance().isEnchantable(s.getId());
    				if (isEnchantable)
    				{
    					final L2EnchantSkillLearn esl = EnchantGroupsTable.getInstance().getSkillEnchantmentBySkillId(s.getId());
    					if (esl != null)
    					{
    						if (s.getLevel() < esl.getBaseLevel())
    						{
    							isEnchantable = false;
    						}
    					}
    					else
    					{
    						isEnchantable = false;
    					}
    				}
    				if (getAioEndTime() > System.currentTimeMillis() && !isGM() && !isInsideZone(ZONE_TOWN))
    				{
    					isDisabled = true;
    				}
    				sl.addSkill(s.getId(), s.getLevel(), s.isPassive(), isDisabled, isEnchantable);
    			}
    		}
    		
    		sendPacket(sl);
    	}

     

    All skills are gathered into a packet that is send only 1 time upon the end of code. This class takes 3500 nanoseconds to be done, aka 0 milliseconds

     

    The only method that retrieve the skills here is just this:

     

    public final L2Skill[] getAllSkills()
        {
            if (_skills == null)
            {
                return new L2Skill[0];
            }
            return _skills.values().toArray(new L2Skill[_skills.values().size()]);
        }

    Basically a Map that is turned into array (no delay at all obviously). 

     

    I did in both methods 

    long ms = System.getNanoTime(); 

    System.out.println(System.getNanoTime() - ms); and it show all 0 MS in total.  MAX 1 ms. So the reason of 2 sec delay is not justified

  13. 21 minutes ago, .Elfocrash said:

    It's client side. The server is bombarding the client with one packet per skill and it essentially gets flooded.

    Wait wait.. the skillList is a packet that contains a sub-list so basically  on a List you load all getPlayerAvailableSkills 

    and u add them on SkillList packet and then at the end u send 1 time the packet.  so ?  It's not about fix. 1.5 sec delay is no problem is just

    it make me so fucking curious.. i did berchmarks and is so fast that even in nanoseconds it show 3500 to complete all giveSkillListToPlayer(); 

  14. What would be the reason of pause the tread of player for like 1.5 to 2 seconds upon sendSkillList? 

    I did berchmark on the

    public void sendSkillList(final L2PcInstance player)

    code it return literally 0.06 millisecond respond time So thats no the reason. There is no other code

    both admin (give_all_skills) and the sub-class use the sendSkillList(player);  which it really has no delay since i made it's List and it's really fast.

    What else would cause this 1.5 - 2 second delay upon give skill list?  Give some advice

  15. 24 minutes ago, Griunvaldas said:

    Yeah, right :D First, stupid BR/RU doesn't know how to compile Java, not speaking about OFF. Second, even if they manage to do that, server will be full of problems and totally not ready for production.

    Except cases when person who knows what he does, is hired to fix all the stuff. And maybe he will not be stupid after all :)

    Now i kinda love u, wanna go see a movie?

  16. And another proof u are the same person.

    bvMoLbw.png

     

    So basically i wish from the deep of my heart your girlfriend suffer an anal but im sure that fat bitch can handle it. Also Don't worry i got plans for you 

    with your photos and her photos. If you lived in Athens u would see 3 BMW under ur house now and u wouldnt exist you piece of shit trust me. If u got the guts give me a call

    when u come in athens ill handle u in pieces :)

×
×
  • Create New...