Git Product home page Git Product logo

Comments (4)

Boshen avatar Boshen commented on May 18, 2024

cc @YoniFeng, since you are really good at this kind of low level stuff, and I'm learning a lot from you.

from oxc.

Boshen avatar Boshen commented on May 18, 2024

Relevant CPU profile:

image

from oxc.

YoniFeng avatar YoniFeng commented on May 18, 2024

I need to get a setup for profiling native applications(on Windows..), been lazy so far.
Most of my profiling analysis experience is from a previous job where the profiling was already instrumented on production machines, and the data was served on a silver platter (and it was mostly non-native).

From reading indextree's doc and skimming the code, I'm skeptical that hand-rolling this tree on bumpallo will see significant gains.
However, I did notice that the append we use in create_ast_node isn't specialized for a new node.

pub fn checked_append<T>(
        self,
        new_child: NodeId,
        arena: &mut Arena<T>,
    ) -> Result<(), NodeError> {
        if new_child == self {
            return Err(NodeError::AppendSelf);
        }
        if arena[self].is_removed() || arena[new_child].is_removed() {
            return Err(NodeError::Removed);
        }
        if self.ancestors(arena).any(|ancestor| new_child == ancestor) {
            return Err(NodeError::AppendAncestor);
        }
        new_child.detach(arena);
        insert_with_neighbors(arena, new_child, Some(self), arena[self].last_child, None)
            .expect("Should never fail: `new_child` is not `self` and they are not removed");

        Ok(())
    }

In our case, everything above insert_with_neighbors() is redundant work for us.
Even within insert_with_neighbors(), there's a detach_from_siblings() call which is redundant when we know the inserted node is new (and even beyond the "new node" use case - it's redundant because it was just performed in detach).

In your profiling screenshot detach_from_siblings is 50ms which would get shaved off.
Probably worth checking out some sort of an append_new_node fast path, where it's the user's responsibility to uphold assumptions.

TL;DR I think making trying to make changes in indextree makes more sense, at least for a first approach.
You can assign this issue to me.

from oxc.

Boshen avatar Boshen commented on May 18, 2024

Done in #122.

from oxc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.