Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Codelite hand during rebuild project #3298

Closed
rozhuk-im opened this issue Jan 27, 2024 · 6 comments
Closed

[Bug]: Codelite hand during rebuild project #3298

rozhuk-im opened this issue Jan 27, 2024 · 6 comments
Assignees
Labels

Comments

@rozhuk-im
Copy link
Contributor

rozhuk-im commented Jan 27, 2024

What happened?

Codelite infinite call BuildTab::OnBuildAddLine have no idea why: I try to debug this but not found who post events, probably it try to process same event infinite times.
If it rely on ZombieReaperPOSIX::Entry() - this can be reason, because this code may lost events IMHO.

OS: FreeBSD 14/stable

Version

Self compiled

Operating system

Other

Steps to reproduce

git clone https://github.com/rozhuk-im/gtk-mixer.git
Open workspace in Codelite
Try to REBUILD debug configuration

Relevant log output

No response

@rozhuk-im
Copy link
Contributor Author

rozhuk-im commented Jan 28, 2024

Looks like I found why this happen.

Project generate 30+mb log and 500k+ lines of output.

void clRowEntry::InsertChild(clRowEntry* child, clRowEntry* prev)
....
    // Connect the linked list for sequential iteration
    clRowEntry::Vec_t::iterator iterCur =
        std::find_if(m_children.begin(), m_children.end(), [&](clRowEntry* c) { return c == child; });
....

This become very slow after 100k items.

Also lines.erase(lines.begin()); looks slow and can be replaced with:

    auto lines = ::wxStringTokenize(m_buffer, "\n", wxTOKEN_RET_DELIMS);
    wxString remainder;
    //while(!lines.empty()) {
    const size_t cnt = lines.Count();
    for (size_t i = 0; i < cnt; i ++) {
        auto& line = lines[i];

@eranif
Copy link
Owner

eranif commented Jan 29, 2024

Thanks, looking forward to apply your PR. I posted 2 comments on it (the first comment is crucial, the second is more of a "nit" comment)

@rozhuk-im
Copy link
Contributor Author

#3304 and #3305 also here.
Current limit with 8192 lines mostly unreachable, now limiting callm_view->Commit(); and m_view->ScrollToBottom(); save more CPU time than limiting for lines parse.

@eranif
Copy link
Owner

eranif commented Jan 31, 2024

....
// Connect the linked list for sequential iteration
clRowEntry::Vec_t::iterator iterCur =
std::find_if(m_children.begin(), m_children.end(), [&](clRowEntry* c) { return c == child; });
....

This looks redundant. We could use the previous insert and capture the iterator

So the code above this snippet looks like:

    // We need the last item of this subtree (prev 'this' is the root)
    clRowEntry::Vec_t::iterator iterCur = {};
    if(prev == nullptr || prev == this) {
        // make it the first item
        iterCur = m_children.insert(m_children.begin(), child);
    } else {

        // optimization:
        // we often get here by calling AddChild(), so don't loop over the list, check if `prev`
        // is the last item
        if(!m_children.empty() && m_children.back() == prev) {
            iterCur = m_children.insert(m_children.end(), child);
        } else {
            // Insert the item in the parent children list
            clRowEntry::Vec_t::iterator iter = m_children.end();
            iter = std::find_if(m_children.begin(), m_children.end(), [&](clRowEntry* c) { return c == prev; });
            if(iter != m_children.end()) {
                ++iter;
            }
            // if iter is end(), than the is actually appending the item
            iterCur = m_children.insert(iter, child);
        }
    }

eranif added a commit that referenced this issue Jan 31, 2024
@rozhuk-im
Copy link
Contributor Author

What happen with changes from 0f46067 ?

My second attempt was to remove all Vec_t crap and leave only double linked list. I am almost done this, but getters that returns m_children confuse me and I revert back to code from PR.
Later I think that getter can be implemented by create+fill Vec_t from list.

I really does not understand design: why Vec_t used with double linked list: they do almost same things.
Double linked list can be implemented by TAILQ_INIT() staff, that available at least on FreeBSD and linux.

@eranif
Copy link
Owner

eranif commented Jan 31, 2024

I merged your changes. After I committed my small fix, I noticed that you did the same in the PR, so I resolved the conflict and merged (from GitHub UI)

eba94a8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants